package cn.learn.pay.wechat.config;

import cn.learn.pay.wechat.offical.sdk.IWXPayDomain;
import cn.learn.pay.wechat.offical.sdk.WXPayConfig;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * @author huangyezhan
 * @version 1.0
 * @date 2021年09月07日17:26
 */
public class MyConfig extends WXPayConfig {

    private final byte[] certData;

    public MyConfig() throws Exception {
        String      certPath   = "E:/openSources/learnspace/learndemo/component/target/classes/apiclient_cert.p12";
        File        file       = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        byte[]      b          = new byte[(int) file.length()];
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }

    @Override
    protected String getAppID() {
        return "1252162292245065729";
    }

    @Override
    protected String getMchID() {
        return "1369571495790989313";
    }

    @Override
    protected String getKey() {
        return "03c66817284445f6b0d970e477622wc2";
    }

    @Override
    protected InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    @Override
    protected IWXPayDomain getWXPayDomain() {
        return WXPayDomainSimpleImpl.instance();
    }

}
